<template>
	<!-- financialdetails财务明细 -->
	<view class="f_wp">
		<view class="f_nav">
			<view :class="{active:navIndex===0}" @click="navTap(0)">订单</view>
			<view :class="{active:navIndex===1}" @click="navTap(1)">转账</view>
		</view>
		<view class="f_list">
			<view class="f_item" v-for="(item,index) in list" :key="index">
				<text class="f_order" v-if="navIndex===0" selectable>订单号：{{item.ordersn}} <text
						class="f_status">{{item.status}}</text></text>
				<text class="f_order" v-if="navIndex===1" selectable>转账号：{{item.ordersn}}
					<text class="f_status">{{item.status}}</text>
				</text>
				<view class="f_sz" v-if="navIndex===0">
					<text>收入：</text>
					<view class="f_sz_money">
						<text>{{item.money}}元</text>
						<text>{{item.paycredit}}米券</text>
					</view>
				</view>
				<view class="f_sz" v-if="navIndex===1">
					<view class="f_sz_money">
						<text>{{item.money}}元</text>
						<text>{{item.credit1}}米券</text>
					</view>
				</view>
				<view class="f_createtime">
					{{item.createtime}}
				</view>
				<view class="f_remark" v-if="navIndex===1">
					备注：{{item.remark}}
				</view>
			</view>
		</view>
		<view class="loading_message">
			<image v-if="isloading" src="../../static/business/loading.gif"></image>
			<view v-if="isempty">到底了~</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				query: {},

				list: [],
				isempty: false,
				isloading: false,
				navIndex: 0,
			}
		},
		onReachBottom() {
			if (this.navIndex === 0) this.getorderList();
			if (this.navIndex === 1) this.getzzList();
		},
		onLoad(optoion) {
			this.query = {
				uid: optoion.uid,
				type: optoion.type,
				begintime: optoion.begintime,
				endtime: optoion.endtime,
				page: 0
			}
			this.getorderList();
		},
		methods: {
			setIData(data) {
				let length = data.length;
				this.list = this.list.concat(data);
				this.isempty = length <= 0 ? true : false;
			},
			getorderList() {
				this.query.page++;
				this.isloading = true;
				this.$axios('groupMoney/orderquery', 'POST', 'supplier', this.query).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.setIData(res.data.data);
					}
				})
			},
			getzzList() {
				this.query.page++;
				this.isloading = true;
				this.$axios('groupMoney/zzquery', 'POST', 'supplier', this.query).then(res => {
					this.isloading = false;
					if (res.data.code == 200) {
						this.setIData(res.data.data);
					}
				})
			},
			navTap(e) {
				if (e === this.navIndex) return;
				this.navIndex = e;
				this.query.page = 0;
				this.list = [];
				this.isempty = false;
				if (e === 0) this.getorderList();
				if (e === 1) this.getzzList();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f2f2f2;
		color: $font-color-dark;
		padding-bottom: 130upx;
	}

	.f_nav {
		background-color: #fff;
		display: flex;
		align-items: center;
		position: fixed;
		left: 0;
		line-height: 80upx;
		width: 100%;
		z-index: 100;
	}

	.f_nav view {
		flex: 1;
		text-align: center;
		position: relative;
	}

	.active {
		color: $base-color;
	}

	.active:after {
		content: '';
		border-bottom: 2px $base-color solid;
		position: absolute;
		bottom: 0;
		left: 50%;
		transform: translateX(-50%);
		width: 40upx;
	}

	.f_list {
		padding-top: 100upx;
	}

	.f_item {
		background-color: #fff;
		padding: 20upx;
		margin-bottom: 20upx;
	}

	.f_order {
		display: block;
		padding-bottom: 10upx;
	}

	.f_status {
		color: #FF0000;
		float: right;
	}

	.f_sz,
	.f_sz_money {
		display: flex;
		align-items: center;
	}

	.f_sz_money,
	.f_sz_money text {
		flex: 1;
	}

	.f_createtime {
		color: $font-color-light;
		padding-top: 10upx;
	}

	.f_remark {
		color: $base-color;
		padding-top: 10upx;
	}

	.loading_message {
		padding: 40upx;
		color: #0062CC;
		text-align: center;
	}

	.loading_message image {
		height: 50upx;
		width: 50upx;
	}
</style>
